<template>
    <div class="ganttWrapper marLR20" id="ganttWrapper">

        <h3 class="marBT20 orangeColor" style="font-size:16px;">时间范围:{{timeRange}}</h3>

        <el-row>
            <el-col :span="24">
                <!-- <el-tag class="marBT10" type="warning" style="cursor:pointer;" v-show="proAnalyObj && proAnalyObj.pro_groups && proAnalyObj.pro_groups.length <= 0" @click.native.stop="showAddOneProGroupDialog('新增项目组')">新增项目组</el-tag> -->
                <!-- <el-popover 
                    placement="top-start"
                    width="200"
                    trigger="hover">
                    <template v-if = "proAnalyObj && proAnalyObj.pro_analy_files">
                         <p  v-for = "item of proAnalyObj.pro_analy_files" :key = "item.id" class="ellipsis" :title="item.file_url">
                            {{item.file_url}}
                        </p>
                    </template>
                    <p v-if = "proAnalyObj && proAnalyObj.pro_analy_files && proAnalyObj.pro_analy_files.length <= 0" class="tipNoData">暂无数据</p>
                    <el-tag slot="reference" class="marBT10" type="warning" style="cursor:pointer;" @click.native.stop="showUploadFileDialog">上传 / 查看资料</el-tag>
                </el-popover> -->
                <template v-if="proAnalyObj">
                    <el-tag class="marBT10" type="warning" style="cursor:pointer;" @click.native.stop="showUploadFileDialog">上传资料</el-tag>
                    <el-tag class="marBT10" type="warning" style="cursor:pointer;" v-show="!isFold" @click.native.stop="foldProAnalyGantt">折叠空白行</el-tag>
                    <el-tag class="marBT10" type="warning" style="cursor:pointer;" v-show="isFold" @click.native.stop="getProAnalyGantt">显示全部</el-tag>
                    <el-tag class="marBT10" type="warning" style="cursor:pointer;" v-if=" proAnalyObj.statu !== 4 && proAnalyObj.statu !== 2" @click.native.stop="showStopProAnalyDialog('完成')">完成</el-tag>
                    <el-tag class="marBT10" type="warning" style="cursor:pointer;"  v-if="proAnalyObj.statu !== 2 && proAnalyObj.statu !== 3 && proAnalyObj.statu !== 4" @click.native.stop="showStopProAnalyDialog('暂停')">暂停</el-tag>
                    <el-tag class="marBT10" type="warning" style="cursor:pointer;" v-if="proAnalyObj.statu !== 2 &&  proAnalyObj.statu === 3 && proAnalyObj.statu !== 4 && proAnalyObj.statu !== 1" @click.native.stop="showStopProAnalyDialog('启动')">启动</el-tag>
                    <el-tag class="marBT10" type="warning" style="cursor:pointer;" v-if="(proAnalyObj.examine_result === null || proAnalyObj.examine_result === 3) && !isSureCancel" @click.native.stop="showCancelProAnalyDialog">取消</el-tag>
                </template>
            </el-col>
        </el-row>

        <!-- <ul class='contextmenu' v-show="visible" :style="{left:left+'px',top:top+'px'}" ref="contextmenu">
            <li @click.stop = "showRemarkDialog">添加备注</li>
        </ul> -->
<!-- @row-contextmenu = "rowRightClick" -->
        <el-table
            row-key = "date"
            
            :cell-class-name = "getCellClassName"
            tooltip-effect="light"
            size = "mini"
            border
            :data="tableData"
            @cell-click = "handleCellClick"
            @cell-mouse-enter = "cellMouseEnter"
            @cell-mouse-leave = "cellMouseLeave"
            height="800"
            style="width: 100%">
            <el-table-column
                width = "100"
                :resizable = "false"
                prop = "date"
                label="日期">
                    <template slot-scope="scope">
                        <span v-html="getDate(scope.row)" :class="scope.row.isStartNewMoth ? 'orangeColor' : ''"></span>
                    </template>
            </el-table-column>

           <el-table-column
                width = "70"
                :resizable = "false"
                show-overflow-tooltip
                :label="proAnalyObj && proAnalyObj.pro_analy_name">
                <!-- :label="proAnalyObj && proAnalyObj.pro_analy_name"> -->
                <template slot-scope="scope">
                    <!-- <el-popover
                        v-show = "getProAnalyJournal(scope.row.date).split('|').length > 1"
                        placement="top-start"
                        width="200"
                        trigger="hover">
                        <p v-for = "(item,index) of getProAnalyJournal(scope.row.date).split('|')" :key = "index" v-html="item"></p>
                        <div slot="reference" v-text="getProAnalyJournal(scope.row.date) !== '' ? getProAnalyJournal(scope.row.date).split('|').pop().split('(')[0] + '...' : ''"></div>
                    </el-popover> -->
                    <!-- <div v-text="getProAnalyJournal(scope.row.date).split('|').length <= 1 ? getProAnalyJournal(scope.row.date).split('|').pop().split('(')[0]  : ''"></div> -->
                    <div v-text="getProAnalyJournal(scope.row.date)"></div>
                </template>
            </el-table-column>
            
            <template v-if = "proAnalyObj && proAnalyObj.pro_groups">
                <el-table-column
                    :resizable = "true"
                    show-overflow-tooltip
                    v-for = "(item,index) of proAnalyObj.pro_groups"
                    :key = "item.id"
                    :index = "index"
                    :column-key = "'group_' +item.id"
                    :label="item.pro_group_name + (item.is_diss === 2 ? '(解散)' :'')">
                        <el-table-column
                            show-overflow-tooltip
                            v-for = "(item1,index1) of item.pro_group_users"
                            :key = "item1.pro_user_id"
                            :column-key = "'proUser_' + item1.pro_user_id + '|' + item1.id"
                            :index = "index1"
                            :label="item1.pro_users.user_name">
                            <template slot-scope="scope">
                                <el-popover
                                    v-show = "getUserJournal(scope.row.date,item1.pro_user_id).split('|').length > 1"
                                    placement="top-start"
                                    width="200"
                                    trigger="hover">
                                    <p v-for = "(item2,index2) of getUserJournal(scope.row.date,item1.pro_user_id).split('|')" :key = "index2" v-text="item2"></p>
                                    <div slot="reference" v-text="getUserJournal(scope.row.date,item1.pro_user_id) !== '' ? getUserJournal(scope.row.date,item1.pro_user_id).split('|').pop().split('(')[0] + '...' : ''" style="display:inline-block;"></div>
                                </el-popover>
                                <div v-text="getUserJournal(scope.row.date,item1.pro_user_id).split('|').length <= 1 ? getUserJournal(scope.row.date,item1.pro_user_id).split('|').pop().split('(')[0] : ''" style="display:inline-block;"></div>
                                <!-- 备注内容 -->
                                <el-popover
                                    v-show = "item1.pro_user_remarks.filter((val) => val.time.split(' ')[0] === scope.row.date).length >= 1"
                                    placement="top-start"
                                    width="200"
                                    trigger="hover">
                                    <p v-for = "(item3,index3) of item1.pro_user_remarks.filter((val) => val.time.split(' ')[0] === scope.row.date)" :key = "index3" class="ellipsis">
                                        {{item3.content}}
                                        <span class = "tipRed">{{item3.is_lock === 2 ? '(被锁定)' : ''}}</span>
                                        <!-- <span class="fr" v-if="getLoginUserId === item1.pro_user_id && "> -->
                                        <span class="fr" v-if="isCanLock">
                                            <span title="解锁" class="marLR20" style="cursor:pointer;" v-if = "item3.is_lock === 2"><icon name="unLock" class="scaleIcon3 svgColor" @click.native.stop="unLockProUserRemark(item3,index3)"></icon></span>
                                            <span title="锁定" class="marLR20" style="cursor:pointer;" v-else><icon name="lock" class="scaleIcon1 svgColor" @click.native.stop="lockProUserRemark(item3)"></icon></span>
                                        </span>
                                        <!-- <span title="解锁" class="fr marLR20" style="cursor:pointer;" v-if = "item3.is_lock === 2"><icon name="unLock" class="scaleIcon3 svgColor" @click.native.stop="unLockProUserRemark(item3,index3)"></icon></span> -->
                                        <!-- <span title="锁定" class="marLR20 fr" style="cursor:pointer;" v-else><icon name="lock" class="scaleIcon1 svgColor" @click.native.stop="lockProUserRemark(item3)"></icon></span> -->
                                        <!-- <span title="锁定" class="marLR20 fr" style="cursor:pointer;" v-else><icon name="lock" class="scaleIcon1 svgColor" @click.native.stop="lockProUserRemark(item3.id,item1.pro_user_remarks,index3)"></icon></span> -->
                                    </p>
                                    <i slot="reference" class="redDot"></i>
                                </el-popover>
                                <!-- 资料 -->
                                <el-popover
                                    v-if="proAnalyObj.pro_analy_files.filter((val) => {return val.submit_time.split(' ')[0] === scope.row.date}).length > 0"
                                    placement="top-start"
                                    width="200"
                                    trigger="hover">
                                    <el-table
                                        tooltip-effect="light"
                                        border
                                        size = "mini"
                                        :data="proAnalyObj.pro_analy_files.filter((val) => val.submit_time.split(' ')[0] === scope.row.date)"
                                        style="width: 100%">
                                        <el-table-column
                                            prop="file_url"
                                            show-overflow-tooltip
                                            label="资料路径">
                                        </el-table-column>
                                        <el-table-column
                                            show-overflow-tooltip
                                            label="上传人">
                                            <template slot-scope="scopeFile">
                                                {{scopeFile.row.user.user_name}}
                                            </template>
                                        </el-table-column>
                                        <el-table-column
                                            prop="submit_time"
                                            show-overflow-tooltip
                                            label="上传时间">
                                        </el-table-column>
                                    </el-table>
                                    <span slot="reference" title="查看资料" class="marLR20 fr" style="cursor:pointer;"><icon name="fileData" class="scaleIcon1 svgColor"></icon></span>
                                </el-popover>
                            </template>
                        </el-table-column>
                </el-table-column>
            </template>

        </el-table>

        <!-- 上传资料弹框 -->
        <!-- v-dialogDrag -->
        <el-dialog
            :close-on-click-modal = "false"
            ref = "dialog"
            v-dialogDrag
            class="posClass"
            width="640px"
            title = "上传文件资料"
            :visible.sync="dialogFileVisible"
            :before-close = "beforeClose"
            center>
            <el-form :model="uploadFileFrm" status-icon :rules="uploadFileFrmRules" ref="uploadFileFrm" label-width="100px">
                    <el-form-item label="上传时间" prop="uploadFileTime">
                        <el-date-picker
                            v-model="uploadFileFrm.uploadFileTime"
                            type="datetime"
                            class="inputTxtWrapper"
                            value-format="yyyy-MM-dd HH:mm:ss"
                            placeholder="选择上传时间">
                        </el-date-picker>
                    </el-form-item>
                    <el-form-item label="选择资料" prop="fileList">
                        <el-upload
                            :lock-scroll = "false"
                            multiple  = true
                            class="upload-demo"
                            ref="uploadFile"
                            action=""
                            :before-remove = "beforeRemove"
                            :on-change = "handleFileChange"
                            :auto-upload="false">
                            <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
                            <div slot="tip" class="el-upload__tip">单个文件不能超过1M!</div>
                        </el-upload>
                    </el-form-item>
                </el-form>
                <!-- <el-row>
                    <el-col :span="24">
                        <el-upload
                            :lock-scroll = "false"
                            multiple  = true
                            class="upload-demo"
                            ref="uploadFile"
                            action=""
                            :before-remove = "beforeRemove"
                            :on-change = "handleFileChange"
                            :auto-upload="false">
                            <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
                            <div slot="tip" class="el-upload__tip">单个文件不能超过1M!</div>
                        </el-upload>
                    </el-col>
                </el-row> -->
            <span slot="footer" class="dialog-footer">
                <el-button @click.stop.native = "beforeClose">取消并关闭</el-button>
                <el-button type="primary" @click.stop.native="submitFile">确 定</el-button>
            </span>
        </el-dialog>


        <!-- 备注弹框 -->
        <el-dialog
            v-dialogDrag
            ref = "remarkDialog"
            class="posClass"
            width="680px"
            :title = "currMarkUserObj.userName + '的备注'"
            :visible.sync="isRemarkDialogVisible"
            :before-close = "beforeCloseRemarkDialogVisible"
            center>
                <el-tabs type="border-card"  v-model="markOperatType">
                    <el-tab-pane name="新增备注" label="新增备注">
                        <el-form :model="remarkForm" :rules="remarkFormRules" ref="remarkForm" label-width="100px">
                            <!-- <el-form-item label="姓名">
                                <p class="orangeColor">{{currMarkUserObj.userName}}</p>
                            </el-form-item> -->
                            <el-form-item label="备注时间" prop="time">
                                <el-date-picker
                                    style="width:100%"
                                    class="inputTxtWrapper"
                                    v-model="remarkForm.time"
                                    type="datetime"
                                    value-format="yyyy-MM-dd HH:mm:ss"
                                    placeholder="备注时间">
                                </el-date-picker>
                            </el-form-item>
                            <el-form-item label="备注内容" prop="content">
                                <el-input v-model.trim = "remarkForm.content" placeholder="请输入备注内容" maxlength='100' class="inputTxtWrapper"></el-input>
                            </el-form-item>
                        </el-form>
                    </el-tab-pane>
                    <el-tab-pane name="编辑备注" label="编辑备注">
                        <el-table
                            border
                            ref="multipleTable"
                            :data="currMarkUserObj.proGroupUserObj && currMarkUserObj.proGroupUserObj.proUserRemarks ? currMarkUserObj.proGroupUserObj.proUserRemarks : []"
                            tooltip-effect="light"
                            style="width: 100%"
                            @selection-change="handleSelectionChange">
                            <el-table-column
                            type="selection"
                            align = "center"
                            width="55">
                            </el-table-column>
                            <el-table-column
                            prop="content"
                            align = "center"
                            label="备注内容">
                                <template slot-scope="scope">
                                    <el-input v-model.trim = "scope.row.content" placeholder="请输入备注内容" maxlength='100' class="inputTxtWrapper"></el-input>
                                </template>
                            </el-table-column>
                            <el-table-column
                            prop="time"
                            align = "center"
                            label="备注时间">
                                <template slot-scope="scope">
                                    <el-date-picker
                                        style = "min-width:248px;"
                                        class="inputTxtWrapper"
                                        v-model="scope.row.time"
                                        type="datetime"
                                        value-format="yyyy-MM-dd HH:mm:ss"
                                        placeholder="备注时间">
                                    </el-date-picker>
                                </template>
                            </el-table-column>
                        </el-table>
                    </el-tab-pane>
                </el-tabs>
                <span slot="footer" class="dialog-footer">
                    <el-button @click.stop.native = "beforeRemarkDialogVisible">关闭</el-button>
                    <el-button type="primary" @click.stop.native = "submitRemark" v-show="markOperatType === '新增备注'">确定新增</el-button>
                    <el-button type="primary" @click.stop.native = "updateProUserRemarks" v-show="markOperatType === '编辑备注'">确定修改</el-button>
                    <el-button type="warning" @click.stop.native = "delProUserRemarks" v-show="markOperatType === '编辑备注'">确定删除</el-button>
                </span>
        </el-dialog>

        <!-- <add-one-pro-group :proAnalyId = "proAnalyId" :title="title" :isAddProGroupDiaVisible = "isAddProGroupDiaVisible" :userList = 'userList' @hideAddOneProGroupDialog = "hideAddOneProGroupDialog"></add-one-pro-group> -->

        <!-- <upload-file-dialog :currRowRecord = "currRowRecord" :dialogVisible = "isUploadFileDiaVisible" @hideUploadFileDialog = "hideUploadFileDialog"></upload-file-dialog> -->
        <!-- 暂停 / 启动 / 完成 立项分析弹框 -->
        <toggle-start-or-stop-dialog :proAnalyId = "proAnalyId" :toggleStr = "toggleStr" :proAnalyAuditCount="proAnalyObj && proAnalyObj.pro_analy_audit_count" :isToggleStartOrStopDiaVisible = "isToggleStartOrStopDiaVisible" @hideToggleStartOrStopDiaVisible = "hideToggleStartOrStopDiaVisible"></toggle-start-or-stop-dialog>

        <cancel-pro-analy-dialog 
             :proAnalyId = "proAnalyId"
              :proAnalyAuditCount="proAnalyObj && proAnalyObj.pro_analy_audit_count"
            :calcelDialogVisible = "calcelDialogVisible" 
            :powerUserList = "powerUserList" 
            @hideCancelProAnalyDialog = "hideCancelProAnalyDialog"
            @changeProAnalyStatu = "changeProAnalyStatu"></cancel-pro-analy-dialog>

    </div>
</template>

<script>

//      window.onload = function () {
//     var loadTime = window.performance.timing.domContentLoadedEventEnd-window.performance.timing.navigationStart; 
//     console.log('Page load time is '+ loadTime);
// }

    import http from '@/assets/js/http'
    import _g from '@/assets/js/global'
    // import addOneProGroup from './component/addOneProGroup'
    import toggleStartOrStopDialog from './component/toggleStartOrStopDialog'
    import cancelProAnalyDialog from './component/cancelProAnalyDialog'
    import { mapGetters } from 'vuex'
    // import uploadFileDialog from './component/uploadFileDialog'

    export default {
        inject:['reload'],
        mixins: [http],
        components:{
            // addOneProGroup,
            toggleStartOrStopDialog,
            cancelProAnalyDialog
            // uploadFileDialog
        },
        computed: {
            ...mapGetters([                                                                         //  用户权限
                'getRoles', 'getLoginUserId', 'getStaffNum'
            ]),
            timeRange(){
                let str = ''
                const tableData = this.tableData
                if(tableData.length > 0){
                    if(tableData.length === 1){
                        str = '' + tableData[0].date
                    }else{
                        str = '' + tableData[0].date + ' 到 ' + tableData[tableData.length - 1].date
                    }
                }
                return str;
            }
        },
        data() {

            const validatorFile = (rule,value,callback) => {
                let isBigThanOneM = false// 默认大小不超过1M
                let fileName = ''
                for(let item of value){
                    if(item.size >= 1024 * 1024){
                        fileName = item.name
                        isBigThanOneM = true
                    }
                }
                if(isBigThanOneM){//    如果有资料大小超过1M
                    return callback(new Error(fileName + '大小不能超过1M'))
                }else{
                    callback()
                }
            }

            return {
                globalStartTime : null,// 甘特图开始时间
                globalEndTime : null,// 甘特图结束时间

                isCanLock :false,// 默认不能锁定和解锁
                // isCellClicked : false,//    默认没有单元格被点击
                // currCell : null,//  当前被点击的单元格

                delRemarkIdsArr : [],//待删除备注id数组

                currMarkUserObj : {
                    columnKey : null,
                    userName : '',
                    proGroupUserObj : null,
                },//   当前备注的人员信息

                currTimeStr : '',//..当前行应时间
                markOperatType : '新增备注',//   备注操作类型:新增备注   修改 / 删除备注

                isFold : false,//   默认没有折叠空白行

                currUserMark : null,//  当前用户的一条备注

                isSureCancel : false,// 默认没有取消过

                proAnalyId : null,

                calcelDialogVisible : false,// 取消立项分析弹框默认隐藏
                powerUserList : [],//   拥有审核立项分析取消权限的人

                toggleStr : '暂停',
                isToggleStartOrStopDiaVisible : false,//    暂停立项分析弹框默认隐藏

                // isAddProGroupDiaVisible : false,// 新增项目组弹框默认隐藏
                // userList : [],//    所有人员列表
                // title : '',//   新增项目组弹框标题

                /* 备注 */
                isRemarkDialogVisible : false,//    备注弹框默认隐藏
                remarkDiaTitle : '',//..备注弹框标题
                remarkForm:{
                    remarkId : null,//  备注id
                    index : null,// 备注索引
                    content : '',
                    time : moment().format('YYYY-MM-DD HH:mm:ss')
                },
                

                downFileList : [],//    待下载文件

                dialogFileVisible : false,//    上传资料弹框默认隐藏

                uploadFileFrm:{
                    fileList : [],//    待上传文件
                    uploadFileTime : moment().format('YYYY-MM-DD HH:mm:ss'),//..上传资料时间
                },

                proAnalyId :null,// 所属立项分析id
                
                // 右键控制菜单
                visible: false,
                top: 0,
                left: 0,

                tableData : [],//   时间年月日
                // proArr : [],//  项目
                proAnalyObj : null,//   立项分析对象 

                paramStr : '',//..参数字符串

                remarkFormRules : {
                    content : [
                        {required:true,message:'请输入备注内容',trigger:'blur'}
                    ],
                    time : [
                        {required:true,message:'请选择备注时间',trigger:'blur'}
                    ]
                },
                uploadFileFrmRules : {
                    fileList:[
                        {required:true,message:'请选择资料',trigger:"blur"},
                        {validator:validatorFile,trigger:'blur'},
                    ],
                    uploadFileTime : [
                        {required:true,message:'请选择资料上传时间',trigger:"blur"}
                    ],
                }
        }
    },
    watch : {
        // visible(value) {
        //     if (value) {
        //         document.body.addEventListener('click', this.closeMenu)
        //     } else {
        //         document.body.removeEventListener('click', this.closeMenu)
        //     }
        // },
    },
    created() {
        this.proAnalyId = parseInt(this.$route.query.proAnalyId)
        // this.getProAnalyGantt()
        this.foldProAnalyGantt()
    },
    methods: {
        /* 解锁单条人员备注 */
        unLockProUserRemark(obj){
            const that = this
            const remarkId = obj.id//   所属备注id

            that.$confirm('是否确认解锁?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
                center: true
            }).then(() => {
                    _g.showLoading('提交中')
                    that.apiPost('admin/task/unLockProUserRemark', {remarkId}).then((res) => {
                        _g.showLoading().close()
                        if(typeof res === 'string'){
                            res = JSON.parse(res)
                        }
                        if (res.code != 200) {
                            that.handleError(res)
                        } else {
                            if(res.data.isSuccess === 0){             //  成功
                                _g.toastMsg("success", res.message)
                                that.$set(obj,'is_lock',1)
                                // that.isFold ?  that.foldProAnalyGantt() : that.getProAnalyGantt()
                            }else if(res.data.isSuccess === 1){
                                _g.toastMsg("error", res.message)
                            }
                        }
                    })
            }).catch(() => {});
        },
        /* 锁定单条人员备注 */
        lockProUserRemark(obj){
            const that = this
            const remarkId = obj.id//   所属备注id

            that.$confirm('是否确认锁定?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
                center: true
            }).then(() => {
                    _g.showLoading('提交中')
                    that.apiPost('admin/task/lockProUserRemark', {remarkId}).then((res) => {
                        _g.showLoading().close()
                        if(typeof res === 'string'){
                            res = JSON.parse(res)
                        }
                        if (res.code != 200) {
                            that.handleError(res)
                        } else {
                            if(res.data.isSuccess === 0){             //  成功
                                _g.toastMsg("success", res.message)
                                that.$set(obj,'is_lock',2)
                                // that.isFold ?  that.foldProAnalyGantt() : that.getProAnalyGantt()
                            }else if(res.data.isSuccess === 1){
                                _g.toastMsg("error", res.message)
                            }
                        }
                    })
            }).catch(() => {});
        },
        /* 批量更新项目组某个人员备注 */
        updateProUserRemarks(){
            const that = this
            const proUserRemarks = that.currMarkUserObj.proGroupUserObj.proUserRemarks// 修改备注

            const proAnalyId = that.proAnalyId//    所属立项分析id
            const updateMarkArr = []

            const proGroupUserRecordId = parseInt(that.currMarkUserObj.columnKey.split('|')[1])//项目组人员记录id

            for(let item of proUserRemarks){
                if(item.content === '' || item.time === ''){
                    _g.toastMsg('warning','备注内容或备注时间不能为空!')
                    return
                }else{
                    updateMarkArr.push(item.id + '|' + item.content + '|' +item.time)
                }
            }

            _g.showLoading('提交中')
            that.apiPost('admin/task/updateProUserRemarks',{updateMarkArr,proAnalyId}).then((res) => {
                _g.showLoading().close()
                if(typeof res === 'string'){
                    res = JSON.parse(res)
                }
                if (res.code != 200) {
                    that.handleError(res)
                } else {
                    if(res.data.isSuccess === 0){             //  成功
                        _g.toastMsg("success", res.message)
                        that.isFold ?  that.foldProAnalyGantt() : that.getProAnalyGantt()
                        for(let item of that.proAnalyObj.pro_groups[0].pro_group_users){
                            if(item.id == proGroupUserRecordId){
                                for(let item1 of proUserRemarks){
                                    for(let markObj of item.pro_user_remarks){
                                        if(item1.id === markObj.id){//    如果匹配修改的记录
                                            console.log(1)
                                            that.$set(markObj,'content',item1.content)
                                            that.$set(markObj,'time',item1.time)
                                            break
                                        }
                                    }
                                }
                                break
                            }
                        } 
                        that.beforeRemarkDialogVisible()
                    }else if(res.data.isSuccess === 1){
                        _g.toastMsg("error", res.message)
                    }else if(res.data.isSuccess === 2){
                        _g.toastMsg("warning", res.message)
                        that.beforeRemarkDialogVisible()
                    }
                }
            })
        },
        /* 备注表格复选框事件处理函数 */
        handleSelectionChange(selection){
            const delRemarkIdsArr = this.delRemarkIdsArr
            console.log('selection = ',selection)
            selection.map((item,index) => {
                delRemarkIdsArr.push(item.id)
            })
            this.delRemarkIdsArr = delRemarkIdsArr
        },
        /* 单元格点击事件处理函数 */
        handleCellClick(row, column, cell, event){
            console.log(row, column, cell, event)
            let currMarkUserObj = null
            let proGroupUserId = null// 项目组人员记录id
            let proGroupUserObj = null// 项目组人员记录对象
            let proUserRemarks = []// 项目组人员备注
            const proGroupUsers = this.proAnalyObj.pro_groups[0].pro_group_users

            let currProUserId = null//  当前项目人员id

            if(column.columnKey !== undefined && column.columnKey.substr(0,8) === 'proUser_'){
                //     if(cell.classList.contains('bor2')){
                //          cell.classList.remove('bor2')
                //     }else{

                // cell.classList.add('bor2')
                // this.isCellClicked = true
                // this.currCell = cell
                //     }
                currProUserId = parseInt(column.columnKey.split('_')[1].split('|')[0]);
                if(parseInt(this.getLoginUserId) !== currProUserId){// 如果当前登录人员不等于当前点击的项目人员，则禁止编辑备注
                    return
                }
                proGroupUserId = parseInt(column.columnKey.split('|')[1])

                // 查询对应的项目组记录信息
                for(let item of proGroupUsers){
                    if(proGroupUserId === item.id){
                        for(let logObj of item.pro_user_remarks){
                            if(logObj.time.split(' ')[0] === row.date && logObj.is_lock === 1){// 匹配时间且备注未被锁定
                                proUserRemarks.push(JSON.parse(JSON.stringify(logObj)))
                            }
                        }
                        proGroupUserObj = {
                            proGroupUserId,
                            proUserRemarks
                        }
                        break
                    }
                }


                currMarkUserObj = {
                    oldTimeStr : row.date,
                    columnKey : column.columnKey,
                    userName : column.label,
                    proGroupUserObj
                }
                this.currMarkUserObj = currMarkUserObj
                this.showRemarkDialog()
            }
            // console.log(row, column, cell, event)
            
        },
        /* 当单元格鼠标离开时的事件处理函数 */
        cellMouseLeave(row,column,cell,event){
            if(column.columnKey !== undefined && column.columnKey.substr(0,8) === 'proUser_'){
                // if(this.currCell && this.isCellClicked){// 如果存在被点击的单元格且备注弹框已被关闭
                //     this.currCell.remove('bor2')
                //     this.currCell = null
                //     this.isCellClicked = false
                // }else{
                    cell.classList.remove('bor2')
                // }
            }
        },
        /* 当单元格 hover 进入时的事件处理函数 */
        cellMouseEnter(row, column, cell, event){
            if(column.columnKey !== undefined && column.columnKey.substr(0,8) === 'proUser_'){
                cell.classList.add('bor2')
            }
        },
        /* 折叠立项分析甘特图 */
        foldProAnalyGantt(){
            const that = this
            const proAnalyId = that.proAnalyId
            _g.showLoading('提交中')
            that.apiPost('admin/task/foldProAnalyGantt',{proAnalyId}).then((res) => {
                _g.showLoading().close()
                if(typeof res === 'string'){
                    res = JSON.parse(res)
                }
                if (res.code != 200) {
                    that.handleError(res)
                } else {
                    if(res.data.isSuccess === 0){             //  成功
                        that.tableData = res.data.result
                        that.isFold = true
                        // that.proAnalyObj = {}
  
                        that.proAnalyObj = res.data.proAnaly

                        for(let item of that.proAnalyObj.pro_groups){
                            for(let item1 of item.pro_group_users){
                                if(item1.user_type === 1 || item1.user_type === 2 || item1.user_type === 4){//  如果为项目经理或产品经理
                                    console.log(that.getLoginUserId)
                                    console.log(item1.pro_user_id)
                                    if(that.getLoginUserId == item1.pro_user_id){// 如果当前登录人员为项目人员
                                    that.isCanLock = true 
                                    break
                                    }
                                }
                            }
                        }
                        that.globalStartTime = res.data.global_start_time
                        that.globalEndTime = res.data.global_end_time
                    }else if(res.data.isSuccess === 1){
                        _g.toastMsg("error", res.message)
                    }
                }
            })
        },
        /* 查询拥有立项分析取消审核权限的未离职人员 */
        getExanmiProAnalyCancelPowerUsers(){
            const that = this

            _g.showLoading('加载中')
            that.apiPost('admin/task/getExanmiProAnalyCancelPowerUsers').then((res) => {
                _g.showLoading().close()
                if(typeof res === 'string'){
                    res = JSON.parse(res)
                }
                if (res.code != 200) {
                    that.handleError(res)
                } else {
                    if(res.data.isSuccess === 0){             //  成功
                        // _g.toastMsg("success", res.message)
                        if(res.data.result.length > 0){
                            that.powerUserList = res.data.result
                            that.calcelDialogVisible = true
                        }else{
                            _g.toastMsg('warning',res.message)
                        }
                    }else if(res.data.isSuccess === 1){
                        _g.toastMsg("error", res.message)
                    }
                }
            })
        },
        /* 显示取消立项分析弹框 */
        showCancelProAnalyDialog(){
            if(this.powerUserList.length > 0){//    如果已经请求过
                this.calcelDialogVisible = true
            }else{
                this.getExanmiProAnalyCancelPowerUsers()
            }
        },
        /* 隐藏取消立项分析弹框 */
        hideCancelProAnalyDialog(str) {
            this.calcelDialogVisible = false
            if(str === '取消立项分析'){
                this.isSureCancel = true
                this.isFold ?  this.foldProAnalyGantt() : this.getProAnalyGantt()
            }
        },
        /* 确认立项 */
        sureProAnaly(){
            const that = this
            const proAnalyId = that.proAnalyId

            const proAnalyAuditCount = that.proAnalyObj.pro_analy_audit_count
            that.$confirm('是否确认立项?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
                center: true
            }).then(() => {
                    _g.showLoading('提交中')
                    that.apiPost('admin/task/sureProAnaly', {proAnalyId,proAnalyAuditCount}).then((res) => {
                        _g.showLoading().close()
                        if(typeof res === 'string'){
                            res = JSON.parse(res)
                        }
                        if (res.code != 200) {
                            that.handleError(res)
                        } else {
                            if(res.data.isSuccess === 0){             //  成功
                                _g.toastMsg("success", res.message)
                                that.isFold ?  that.foldProAnalyGantt() : that.getProAnalyGantt()
                                // that.changeProAnalyStatu(index,'确认立项')
                            }else if(res.data.isSuccess === 1){
                                _g.toastMsg("error", res.message)
                            }
                        }
                    })
            }).catch(() => {});
        },
        /* 显示暂停立项分析弹框 */
        showStopProAnalyDialog(str){
            this.toggleStr = str
            this.isToggleStartOrStopDiaVisible = true
        },
         /* 隐藏暂停立项分析弹框 */
        hideToggleStartOrStopDiaVisible(str){
            this.isToggleStartOrStopDiaVisible = false
            this.toggleStr = '暂停'
            if(str === '立项分析暂停或启动或完成成功'){
                this.isFold ?  this.foldProAnalyGantt() : this.getProAnalyGantt()
            }
        },
        /* 启动立项分析 */
        startProAnaly(){
            const that = this
            const proAnalyId = that.proAnalyId

            const proAnalyAuditCount = that.proAnalyObj.pro_analy_audit_count//    审核人员数量
            that.$confirm('是否确认启动?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
                center: true
            }).then(() => {
                    _g.showLoading('提交中')
                    that.apiPost('admin/task/toggleStartOrStop', {proAnalyId,typeStr:'启动',proAnalyAuditCount}).then((res) => {
                        _g.showLoading().close()
                        if(typeof res === 'string'){
                            res = JSON.parse(res)
                        }
                        if (res.code != 200) {
                            that.handleError(res)
                        } else {
                            if(res.data.isSuccess === 0){             //  成功
                                _g.toastMsg("success", res.message)

                                that.isFold ?  that.foldProAnalyGantt() : that.getProAnalyGantt()
                            }else if(res.data.isSuccess === 1){
                                _g.toastMsg("error", res.message)
                            }
                        }
                    })
            }).catch(() => {});
        },
        /* 获取立项分析甘特图日志 */
        getProAnalyJournal(date){
            const proAnalyLog = this.proAnalyObj.pro_analy_log//    获取立项分析日志数组
            let strHtml = ''
            let timeArr = []
            for(let logObj of proAnalyLog){
                timeArr = logObj.start_time.split(' ')
                if(date === timeArr[0]){
                    // strHtml += `<p class= 'ellipsis' title='${logObj.content}'>${logObj.content}</p>|`
                    strHtml = logObj.content
                }else if(new Date(timeArr[0]).getTime() > new Date(date).getTime()){
                    break
                }
            }
            return strHtml
        },
        // getProAnalyJournal(date){
        //     const proAnalyLog = this.proAnalyObj.pro_analy_log//    获取立项分析日志数组
        //     let strHtml = ''
        //     let timeArr = []
        //     for(let logObj of proAnalyLog){
        //         timeArr = logObj.start_time.split(' ')
        //         if(date === timeArr[0]){
        //             // strHtml += `<p class= 'ellipsis' title='${logObj.content}'>${logObj.content}</p>|`
        //             strHtml += `${logObj.content}(${logObj.start_time})|`
        //         }else if(new Date(timeArr[0]).getTime() > new Date(date).getTime()){
        //             break
        //         }
        //     }
        //     if(strHtml !== ''){//..去掉最后一条 |
        //         strHtml = strHtml.substring(0,strHtml.lastIndexOf('|'))
        //     }
        //     return strHtml
        // },
        /* 获取人员甘特图日志 */
        getUserJournal(date,proUserId){
            let strHtml = ''
            let timeArr = []
            
            const proGroups = this.proAnalyObj.pro_groups//    获取立项分析项目组
            if(proGroups.length > 0){
                for(let item of proGroups[0].pro_group_users){
                    if(proUserId === item.pro_user_id){//   如果找到对应项目组人员
                        for(let logObj of item.pro_user_log){
                            timeArr = logObj.start_time.split(' ')
                            if(date === timeArr[0]){
                                // strHtml += `<p class= 'ellipsis' title='${logObj.content}'>${logObj.content}</p>|`
                                strHtml += `${logObj.content}(${logObj.start_time})|`
                            }else if(new Date(timeArr[0]).getTime() > new Date(date).getTime()){
                                break
                            }
                        }
                        break
                    }
                }
            }

            if(strHtml !== ''){//..去掉最后一条 |
                strHtml = strHtml.substring(0,strHtml.lastIndexOf('|'))
            }
            return strHtml
        },
        // /* 获取所有未离职人员的信息(包含组织架构信息) */
        // getAllNotLeaveUsersMsg(str){
        //     const that = this
        //     let currRowRecord = that.currRowRecord
        //     // let  incumList = []

        //     let userList = []

        //      _g.showLoading('加载中')
        //         that.apiPost('admin/users/getAllNotLeaveUsersMsg').then((res) => {
        //             _g.showLoading().close()
        //             if(typeof res === 'string'){
        //             res = JSON.parse(res)
        //             }
        //         if (res.code != 200) {
        //             that.handleError(res)
        //         } else {
        //             if(res.data.isSuccess === 0){             //  成功
        //                 if(res.data.incumList.length <= 0){
        //                     _g.toastMsg('warning','暂无在职人员!')
        //                 }else{
        //                     if(str === '新增项目组'){
        //                         that.isAddProGroupDiaVisible = true
        //                         that.userList = res.data.incumList
        //                     }
        //                 }
        //             }else{
        //                 _g.toastMsg("error", res.message)
        //             }
        //         }
        //     })
            
        // },
        //  /* 显示新增项目组弹框 */
        // showAddOneProGroupDialog(str){
        //     this.title = str
        //     this.getAllNotLeaveUsersMsg(str)
        // },
        //   /* 隐藏新增项目组弹框 */
        // hideAddOneProGroupDialog(str,index) {
        //     this.isAddProGroupDiaVisible = false
        //     this.userList = []
        //     this.title = ''

        //     if(str === '新增项目组'){
        //         this.isFold ?  this.foldProAnalyGantt() : this.getProAnalyGantt()
        //     }
        // },
        /* 格式化时间 */
        getDate(rowData){
            let str = ''
            if(rowData.isStartNewYear){//   如果新的一年的开始
                str = rowData.date
            }else if(rowData.isStartNewMoth){// 如果不是为新的一年的开始，但是为新的一个月的开始
                str = `${'&ensp;'.repeat(5)}${rowData.date.slice(5)}`
            }else{
                str = `${'&ensp;'.repeat(8)}${rowData.date.slice(-2)}`
            }
            return str
        },
        /* 打开修改备注弹框 */
        updateProUserRemark(currUserMark,index){
            this.remarkDiaTitle = '修改备注'
            this.currUserMark = currUserMark
            this.remarkForm.remarkId = currUserMark.id
            this.remarkForm.index = index
            this.remarkForm.content = currUserMark.content
            this.isRemarkDialogVisible = true// 弹框
        },
        /* 批量删除备注 */
        delProUserRemarks(){
            const that = this
            const delRemarkIdsArr = this.delRemarkIdsArr

            const proGroupUsersData = that.proAnalyObj.pro_groups[0].pro_group_users

            // const proUserId = parseInt(that.currMarkUserObj.columnKey.split('_')[1].split('|')[0])//  项目人员id
            const proGroupUserRecordId = parseInt(that.currMarkUserObj.columnKey.split('|')[1])//项目组人员记录id 

            if(delRemarkIdsArr.length <= 0){
                _g.toastMsg("warning", '请选择需删除的备注')
                return
            }
            that.$confirm('是否确认删除所选备注?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
                center: true
            }).then(() => {
                    _g.showLoading('提交中')
                    that.apiPost('admin/task/delProUserRemarks', {delRemarkIdsArr}).then((res) => {
                        _g.showLoading().close()
                        if(typeof res === 'string'){
                            res = JSON.parse(res)
                        }
                        if (res.code != 200) {
                            that.handleError(res)
                        } else {
                            if(res.data.isSuccess === 0){             //  成功
                                _g.toastMsg("success", res.message)
                                for(let delRemarkId of delRemarkIdsArr){
                                    for(let item of proGroupUsersData){
                                        if(item.id === proGroupUserRecordId){
                                            for(let i = item.pro_user_remarks.length - 1;i >= 0;i--){
                                                if(item.pro_user_remarks[i].id === delRemarkId){//  如果找到匹配的人员备注
                                                    item.pro_user_remarks.splice(i,1)
                                                    break
                                                }
                                            }
                                            break
                                        }
                                    }
                                }
                                that.beforeRemarkDialogVisible()
                            }else{
                                _g.toastMsg("error", res.message)
                            }
                        }
                    })
                }).catch(() => {});
        },
        // /* 删除一条备注 */
        // delProUserRemark(remarkId,userRemarks,index){
        //     const that = this
        //     that.$confirm('是否确认删除备注?', '提示', {
        //         confirmButtonText: '确定',
        //         cancelButtonText: '取消',
        //         type: 'warning',
        //         center: true
        //     }).then(() => {
        //             _g.showLoading('提交中')
                    
        //             that.apiPost('admin/task/delProUserRemark', {remarkId}).then((res) => {
        //                 _g.showLoading().close()
        //                 if(typeof res === 'string'){
        //                     res = JSON.parse(res)
        //                 }
        //                 if (res.code != 200) {
        //                     that.handleError(res)
        //                 } else {
        //                     if(res.data.isSuccess === 0){             //  成功
        //                         _g.toastMsg("success", res.message)
        //                         userRemarks.splice(index,1)
        //                     }else{
        //                         _g.toastMsg("error", res.message)
        //                     }
        //                 }
        //             })
        //         }).catch(() => {});
        // },
        /* 判断每个日期下是否有备注 */
        isHasContent(currDate,time){
            if(currDate === time.substring(0,10)){//    如果当前时间下有备注
                return true
            }else{
                return false
            }
        },
        /* 关闭新增备注弹框 */
        beforeRemarkDialogVisible(){
            this.$refs.remarkForm.resetFields()
            this.remarkForm.remarkId = null
            this.remarkForm.index = null
            this.remarkForm.content = ''
            this.remarkForm.time = new Date()
            this.currUserMark = null
            this.isRemarkDialogVisible = false
            this.remarkDiaTitle = ''
            this.markOperatType = '新增备注'
            // this.closeMenu()
        },
        /* 显示新增备注弹框 */
        showRemarkDialog(){
            this.isRemarkDialogVisible = true
            this.remarkDiaTitle = '请填写备注'
        },
        /* 关闭下载资料弹框 */
        beforeCloseDownFileDialog(){
            this.dialogDownloadFileVisible = false
            this.downFileList = []
        },
        /* 确认新增 / 修改备注 */
        submitRemark(){
            const that = this
            let url = 'admin/task/addProUserRemark'

            let paramStr = ''
            let arr = []
            let proGroupUserRecordId = null// 所属项目组人员记录id
            let proUserId = null// 所属项目人员id

            const content =that.remarkForm.content
            const time =that.remarkForm.time

            let data = {}
            const proAnalyId = that.proAnalyId//    所属立项分析id

            const currMarkUserObj = JSON.parse(JSON.stringify(this.currMarkUserObj))

            const oldTimeStr = currMarkUserObj.oldTimeStr// 备注所在行时间

            const currUserMark = that.currUserMark//    当前修改的用户的一条备注
            if(that.remarkForm.remarkId !== null){//    如果为修改备注
                data = {
                    remarkId : that.remarkForm.remarkId,
                    content : that.remarkForm.content,
                }
                url = 'admin/task/updateProUserRemark'
            }else{//    如果为新增备注
                paramStr = currMarkUserObj.columnKey
                arr = paramStr.split('_')
                proGroupUserRecordId = arr[1].split('|')[1]// 所属项目组人员记录id
                proUserId = arr[1].split('|')[0]// 所属项目人员id
                data = {
                    content,proGroupUserRecordId,proUserId,time,proAnalyId
                }
            }
            that.$refs.remarkForm.validate((valid) => {
                if(valid){
                    that.$confirm('是否确认?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning',
                        center: true
                    }).then(() => {
                            _g.showLoading('提交中')
                            
                            that.apiPost(url, data).then((res) => {
                                _g.showLoading().close()
                                if(typeof res === 'string'){
                                    res = JSON.parse(res)
                                }
                                if (res.code != 200) {
                                    that.handleError(res)
                                } else {
                                    if(res.data.isSuccess === 0){             //  成功
                                        _g.toastMsg("success", res.message)
                                        // that.getProAnalyGantt()
                                            if(that.remarkForm.remarkId !== null){//    如果为修改备注
                                                    that.$set(currUserMark,'content',data.content)
                                                    that.$set(currUserMark,'time',data.time)
                                                // that.$router.push(location.href)
                                                // that.isFold ?  that.foldProAnalyGantt() : that.getProAnalyGantt()
                                            }else{//    如果为新增备注
                                                for(let item of that.proAnalyObj.pro_groups[0].pro_group_users){
                                                    if(item.id == proGroupUserRecordId){
                                                        item.pro_user_remarks.push({
                                                            content : res.data.result.content,
                                                            id : parseInt(res.data.result.id),
                                                            time : res.data.result.time,
                                                            user_id : res.data.result.user_id,
                                                            pro_group_user_record_id : res.data.result.pro_group_user_record_id,
                                                        })
                                                        break
                                                    }
                                                }
                                            }
                                        //  that.$nextTick(function(){
                                            
                                        // })
                                        that.beforeRemarkDialogVisible()
                                    }else if(res.data.isSuccess === 1){
                                        _g.toastMsg("error", res.message)
                                    }else if(res.data.isSuccess === 2){
                                        _g.toastMsg("warning", res.message)
                                    }
                                }
                            })
                        }).catch(() => {});
                }
            })
        },
        /* 显示下载资料弹框 */
        showdownLoadFileDialog(){
            const proArr = this.proArr//    所有项目列表
            const downFileList = []//   待下载文件列表
            const paramStr = this.paramStr
            const arr = paramStr.split('|')
            const proId = arr[0].split('_')[1]//    项目id

            for(let pro of proArr){
                if(pro.proId === proId){//  如果找到项目
                    for(let file of pro.proGroup.files){
                        downFileList.push(file)
                    }
                    break
                }
            }

            this.downFileList = downFileList

            this.dialogDownloadFileVisible = true
        },
        /* 显示上传资料弹框 */
        showUploadFileDialog(){
            this.dialogFileVisible = true
        },
        /* 删除文件之前的钩子 */
        beforeRemove(file,fileList){
            const len = this.uploadFileFrm.fileList.length
            for(let i = 0;i < len;i++){
                if(this.uploadFileFrm.fileList[i].name === file.name){
                    this.uploadFileFrm.fileList.splice(i,1)
                }
            }
        },
        /* 文件选择改变事件 */
        handleFileChange(file, fileList){
            this.uploadFileFrm.fileList = fileList.slice()
        },
        /* 关闭弹框 */
        beforeClose(str) {
            this.oldFileList = []
            this.uploadFileFrm.fileList = []
            this.uploadFileFrm.uploadFileTime = ''
            this.$refs.uploadFileFrm.resetFields()
            this.$refs.uploadFile.clearFiles()
            this.dialogFileVisible = false
            
            this.closeMenu()

            if(str === '上传资料成功'){
                this.isFold ?  this.foldProAnalyGantt() : this.getProAnalyGantt()
            }
        },
        /* 上传资料 */
        submitFile(){
            const that = this

            const proAnalyId = that.proAnalyId
            // const proGroupId = parseInt(that.paramStr.split('|')[2])//   所属项目组id

            // if(that.uploadFileFrm.fileList === []){
            //     _g.toastMsg('warning','请选择至少1个文件')
            //     return
            // }

            // for(let item of that.uploadFileFrm.fileList){
            //     if(item.size >= 1024 * 1024){
            //         _g.toastMsg('warning',item.name + '大小不能超过1M')
            //         return
            //     }
            // }
            const formData = new FormData()

            that.$refs.uploadFileFrm.validate((valid) => {
                if(valid){
                    
                    formData.append('proAnalyId',proAnalyId)
                    // formData.append('proGroupId',proGroupId)
                    formData.append('uploadFileTime',that.uploadFileFrm.uploadFileTime)

                    for(let item of that.uploadFileFrm.fileList){
                        formData.append('files[]',item.raw)
                    }
                    // 向后台传送数据

                        that.$confirm('是否确认?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning',
                        center: true
                    }).then(() => {
                            _g.showLoading('提交中')
                            that.apiPost('admin/task/submitProAnalyFile', formData).then((res) => {
                                _g.showLoading().close()
                                if(typeof res === 'string'){
                                    res = JSON.parse(res)
                                }
                                if (res.code != 200) {
                                    that.handleError(res)
                                } else {
                                    if(res.data.isSuccess === 0){             //  成功
                                        _g.toastMsg("success", res.message)
                                        that.beforeClose('上传资料成功')
                                    }else if(res.data.isSuccess === 1){
                                        _g.toastMsg("error", res.message)
                                    }else if(res.data.isSuccess === 2){
                                        _g.toastMsg("warning", res.message)
                                    }
                                }
                            })
                    }).catch(() => {});
                }
            })
        },
        /* 打开右键菜单 */
        openMenu(e,cell) {
            this.visible = true
            // const dom = this.$refs.contextmenu
            // console.log(cell.getBoundingClientRect())
            // const offsetLeft = this.$el.getBoundingClientRect().left // container margin left
            // const offsetLeft = cell.getBoundingClientRect().left // container margin left
            // const offsetLeft = cell.getBoundingClientRect().top // container margin left
            // this.left = e.clientX - offsetLeft + 15 // 15: margin right
            this.left = e.clientX + 15 // 15: margin right
            // this.left = e.clientX // 15: margin right
            // alert(document.getElementById('ganttWrapper').getBoundingClientRect().top)
            const top = document.getElementById('ganttWrapper').getBoundingClientRect().top
            if(top > 0){
                this.top = e.pageY - top
            }else{
                this.top = e.pageY - 220           
            }
            
            // this.top = e.screenY
        },
        /* 关闭右键菜单 */
        closeMenu() {
            if(!this.isRemarkDialogVisible){//  如果备注弹框已经关闭
                this.visible = false
                this.paramStr = ''
            }
        },
        /*  */
        // cellClick(row, column, cell, event){
        rowRightClick(row, column, event){
            window.oncontextmenu = function(e){
                e.preventDefault()
            }
            // console.log(row, column,event)
            if(event.columnKey !== undefined){
                if(event.columnKey.substring(0,8) === 'proUser_'){//..如果是项目人员
                    this.paramStr = event.columnKey
                    this.openMenu(column)
                }else{
                    return
                }
            }else{
                return
            }
        },
        /* 获取用户描述 */
        getUserMsg(currDate,proId,userId,rz){
            for(let item of rz){
                if(currDate === item.startTime){
                    return item.des
                }
            }
        },
        /* 获取单元格对应样式名，显示单元格背景色 */
        getCellClassName({row,column,rowIndex,columnIndex}){
            // console.log('-------------')
            // console.log({row,column,rowIndex,columnIndex})
            // console.log('-------------')
            const proArr = this.proArr
            const YELLOW_BG_COLOR = 'yellowBgColor'
            const GREEN_BG_COLOR = 'greenBgColor'
            const CYAN_BG_COLOR = 'cyanBgColor'
            const RED_BG_COLOR = 'redBgColor'
            const LIGHT_GRAY_BG_COLOR = 'lightGrayBgColor'


            const proAnalyLog = this.proAnalyObj.pro_analy_log
            const proAnalyLogLen = proAnalyLog.length

            const globalStartTime = this.globalStartTime//  甘特图开始时间
            const globalEndTime =  this.globalEndTime//  甘特图结束时间

            if(columnIndex === 1){//    如果为立项分析
                for(let i = 0;i < proAnalyLogLen;i++){
                    if(i < proAnalyLogLen - 1 && proAnalyLog[i].content === '暂停' && proAnalyLog[i + 1].content === '启动'){
                        // if(new Date(row.date) >= new Date(proAnalyLog[i].start_time.split(' ')[0]) && new Date(row.date) < new Date(proAnalyLog[i + 1].start_time.split(' ')[0])){
                        if(new Date(row.date).getTime() > new Date(proAnalyLog[i].start_time).getTime() && new Date(row.date).getTime() < new Date(proAnalyLog[i + 1].start_time).getTime()){
                            return LIGHT_GRAY_BG_COLOR
                        }
                    }

                    // if(proAnalyLog[0].content === '开始' && proAnalyLog[i].content === '完成'){
                        // if(new Date(row.date) >= new Date(proAnalyLog[0].start_time) && new Date(row.date) <= new Date(proAnalyLog[i].start_time)){
                        // if(new Date(row.date).getTime() > new Date(globalStartTime).getTime() && new Date(row.date).getTime() < new Date(globalEndTime).getTime()){
                        //         if(!proAnalyLog[i].content){
                        //             return GREEN_BG_COLOR
                        //         }
                                
                        // }

                }
                 if(new Date(row.date).getTime() > new Date(globalStartTime).getTime() && new Date(row.date).getTime() < new Date(globalEndTime).getTime()){
                        if(proAnalyLog.filter((val) => val.start_time === row.date).length <= 0){// 如果改行日期没有立项分析日志记录
                            return GREEN_BG_COLOR
                        }
                        
                }
            }else{//    如果为人员

            }
        },
        /* 获取项目描述 */
        getProMsg(row,proId){
            let str = ''
            const currTime = row.date// 当前行对应的时间

            const proArr = this.proArr

            for(let item of proArr){
                if(item.proId === proId){// 如果找到对应项目
                    if(item.proStartTime === row.date){//   如果匹配项目开始时间
                        str = '项目计划开始'
                    }

                    if(item.proHangUp.length > 0){//  如果存在挂起记录
                        for(let item1 of item.proHangUp){
                            if(item1.proHangUpTime === row.date){//  如果匹配项目挂起时间
                                str = '项目挂起'
                                break
                            }
                        }
                        for(let item1 of item.proHangUp){
                            if(item1.proInitiaTime !== null && item1.proInitiaTime === row.date){//  如果匹配项目重启时间
                                str = '项目重启'
                                break
                            }
                        }
                    }

                    if(item.proEndTime === row.date){//   如果匹配项目结束始时间
                        str = '项目计划结束'
                    }

                     if(item.proCompleteTime !== null && item.proCompleteTime === row.date){//   如果匹配项目完成时间
                        str = '项目完成'
                    }
                    break
                }
            }
            return str

            // if(){

            // }

            // if(row.pro !== undefined && row.pro[index] !== undefined){
            //     if(row.pro[index].proId === proId){//   如果是当前项目
            //         if(row.pro[index].proStartTime === currTime){
            //             str = '项目开始'
            //         }
            //         if(row.pro[index].proEndTime === currTime){
            //             str = '项目结束'
            //         }
            //     }
            // }
            return str
        },
        /* 加载立项分析甘特图 */
        getProAnalyGantt(){
          _g.showLoading('加载中');
        const that = this
        const proAnalyId = that.proAnalyId

        that.apiPost('admin/task/getProAnalyGantt',{proAnalyId}).then((res) => {

            _g.showLoading().close()
            if(typeof res === 'string'){
                res = JSON.parse(res)
            }
            if (res.code != 200) {
                that.handleError(res)
            } else {
                if(res.data.isSuccess === 0){
                    that.tableData = res.data.result
                    that.proAnalyObj = res.data.proAnaly

                    for(let item of that.proAnalyObj.pro_groups){
                        for(let item1 of item.pro_group_users){
                            if(item1.user_type === 1 || item1.user_type === 2 || item1.user_type === 4){//  如果为项目经理或产品经理
                                if(that.getLoginUserId == item1.pro_user_id){// 如果当前登录人员为项目人员
                                   that.isCanLock = true 
                                   break
                                }
                            }
                        }
                    }

                    that.isFold = false

                    that.globalStartTime = res.data.global_start_time
                    that.globalEndTime = res.data.global_end_time
                }else if(res.data.isSuccess === 1){
                    _g.toastMsg("error", res.message)
                }
            }
        })
      }
    },
    }
</script>

<style lang="less" scoped>
   .contextmenu {
    margin: 0;
    background: #fff;
    z-index: 100;
    position: absolute;
    list-style-type: none;
    padding: 5px 0;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 400;
    color: #333;
    box-shadow: 2px 2px 3px 0 rgba(0, 0, 0, .3);
    li {
      margin: 0;
      padding: 7px 16px;
      cursor: pointer;
      &:hover {
        background: #eee;
      }
    }
  }
</style>
